home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Newton Sample Code 1.2 / Drawing / GetPoly-1 / getPolygon.text < prev    next >
Encoding:
Text File  |  1994-07-07  |  4.0 KB  |  167 lines  |  [TEXT/MPS ]

  1.  
  2. // ---- End Project Data ----
  3.  
  4.  
  5. // ---- File main.t ----
  6.  
  7. // Before Script for "myapp"
  8. // Copyright ©1993-1994 Apple Computer. All rights reserved.
  9.  
  10. myapp :=
  11.    {title: "GetPolygon",
  12.     viewBounds: {left: 0, top: 2, right: 236, bottom: 294},
  13.     viewFormat: 83951953
  14.     ,
  15.     viewSetupFormScript:
  16.       func()
  17.       begin
  18.           local b := GetAppParams();
  19.           constant kMaxWidth := 240;
  20.           constant kMaxHeight := 336;
  21.           
  22.           viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop,
  23.                   Min(b.appAreaWidth, kMaxWidth),
  24.                   Min(b.appAreaHeight, kMaxHeight) );
  25.       
  26.       
  27.       end,
  28.     _proto: protoApp,
  29.     debug: "myapp"
  30.    };
  31.  
  32. dest := /* child of myapp */
  33.    {viewBounds: {top: 187, left: 34, right: 202, bottom: 290},
  34.     viewFormat: 561,
  35.     viewFlags: 33,
  36.     points: nil,
  37.     viewclass: 82,
  38.     debug: "dest"
  39.    };
  40. // View dest is declared to myapp
  41.  
  42.  
  43.  
  44. _view000 := /* child of myapp */
  45.    {viewFlags: 69121,
  46.     viewFormat: 337,
  47.     viewBounds: {left: 9, top: 42, right: 119, bottom: 160},
  48.     viewAddChildScript:
  49.       func(newOne)
  50.       begin
  51.           
  52.           if (newOne.points exists) then
  53.               SetValue(dest, 'points, Clone(newOne.points));
  54.       
  55.           nil;
  56.           //This should return TRUE if you manually added the child
  57.       end,
  58.     viewclass: 77
  59.    };
  60.  
  61.  
  62.  
  63. _view001 := /* child of myapp */
  64.    {viewFlags: 513,
  65.     viewFormat: 336,
  66.     viewBounds: {left: 128, top: 41, right: 231, bottom: 160},
  67.     viewClickScript:
  68.       func(unit)
  69.       begin
  70.           local         array, len, index, b;
  71.           constant     kOpenShape := 7;
  72.       
  73.           // wait until the stroke is done
  74.           while not strokedone(unit) do Sleep(10);    
  75.          // sleep instead of "do nil" so that you do not run down the battery
  76.       
  77.           array := GetPointsArray(unit);
  78.       
  79.           len := length(array);
  80.           setlength(array, len + 2);
  81.           
  82.           b := :GlobalBox();
  83.       
  84.       
  85.           // The GetPointsArray() function returns an array of points which
  86.           // is ordered y, x...so we need to switch the order in preparation
  87.           // for the ArrayToPoints routine. We do this at the same time we
  88.           // insert two extra elements to the beginning of the array and 
  89.           // change "global" stroke points to local points.
  90.           // The two new elements to the array represent the shape type and
  91.           // the number of points.
  92.       
  93.           for index := len - 2 to 0 by -2 do 
  94.           begin
  95.               array[index + 2] := array[index + 1] - b.left;
  96.               array[index + 3] := array[index]     - b.top + 1;
  97.           end;
  98.           
  99.           array[0] := kOpenShape;    // the "polygon shape type" for
  100.                                           // open curve shapes
  101.           array[1] := len / 2;        // how many points in the array? 
  102.       
  103.       
  104.           // copy this new data to the destination view
  105.           setvalue(dest, 'points, arraytopoints(array));     
  106.                           
  107.           // copy this new data to our "shadow view" so that it
  108.           // it looks like the ink is hanging around. We also could
  109.           // create this effect by saving the points array and giving
  110.           // this clView a viewDrawScript to draw the lines...
  111.           setvalue(shadowView, 'points, arraytopoints(array));
  112.           
  113.           RefreshViews();
  114.           nil;
  115.       end,
  116.     viewclass: 74
  117.    };
  118.  
  119.  
  120.  
  121. _view002 := /* child of myapp */
  122.    {text: "Destination polygonView...",
  123.     viewBounds: {left: 0, top: 169, right: 0, bottom: 185},
  124.     viewJustify: 8388658
  125.     ,
  126.     _proto: protoStaticText
  127.    };
  128.  
  129.  
  130.  
  131. _view003 := /* child of myapp */
  132.    {text: "clEditView",
  133.     viewBounds: {left: 32, top: 25, right: 120, bottom: 41},
  134.     viewJustify: 8388609,
  135.     _proto: protoStaticText
  136.    };
  137.  
  138.  
  139.  
  140. _view004 := /* child of myapp */
  141.    {text: "clView",
  142.     viewBounds: {left: 128, top: 25, right: 216, bottom: 41},
  143.     viewJustify: 8388608,
  144.     _proto: protoStaticText
  145.    };
  146.  
  147.  
  148.  
  149. shadowView := /* child of myapp */
  150.    {viewBounds: {left: 128, top: 40, right: 232, bottom: 160},
  151.     viewFlags: 1,
  152.     points: nil,
  153.     viewFormat: 512,
  154.     viewclass: 82,
  155.     debug: "shadowView"
  156.    };
  157. // View shadowView is declared to myapp
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165. // ---- Beginning of section for non used Layout files ----
  166.  
  167. // End of output